package com.carleasoft.mps.core.user;

import com.carleasoft.mps.core.result.ErrorResult;
import com.carleasoft.mps.core.utils.ExceptionUtil;

/**
 * @author taoyujing
 * @date 2021-09-11 09:31
 * @project services
 */
public enum DataType {
    ALL(1,"全部"),ORG_TYPE(2,"指定组织分类"),DESIGNATED_ORGANIZATION(3,"指定组织"),ORG(4,"所在组织"),DESIGNATED_DEPT(5,"指定部门"),DEPT(6,"所在部门")
    ;

    private Integer id;
    private String name;

    private DataType(Integer id, String name) {
        this.id = id;
        this.name = name;
    }
    private DataType(Integer id) {
        this.id = id;
    }

    private DataType(String name) {
        this.name = name;
    }


    public String getName() {
        return this.name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }

    /*
     * 匹配操作码
     * */
    public static DataType sourceOf(Integer id) {
        DataType[] values = DataType.values();
        for (DataType value : values) {
            Integer valueId = value.getId();
            if (value.getId().equals(id)) {
                return value;
            }
        }
        throw ExceptionUtil.create(ErrorResult.PARAMETER_ERROR);
    }

}
